package com.blank.shop.ribbon.provider;

import com.blank.shop.ribbon.ShopRibbonApplication;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Profile;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <br/>Date 2021/8/31
 * <br/>Time 16:25:06
 *
 * @author _blank
 */
@Profile({ShopRibbonApplication.SERVER_PROVIDER_1, ShopRibbonApplication.SERVER_PROVIDER_2})
@RestController
public class RibbonProviderController {

    @Value("${server.port}")
    private Integer serverPort;
    @Value("${spring.application.name}")
    private String applicationName;

    @PostMapping(path = {"say-hello"})
    public ResponseEntity<String> sayHello() {
        final String body = "来自" + this.applicationName + "端口[" + this.serverPort + "] ribbon 的问好！";
        return ResponseEntity.ok(body);
    }

}
